package com.heima.wemedia.listener;

import com.heima.wemedia.service.WmNewsAutoScanService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * author Link
 *
 * @version 1.0
 * @date 2025/4/13  15:25
 */
@Component
@RequiredArgsConstructor
@Slf4j
public class ReviewArticleDelayListener {

    private final WmNewsAutoScanService wmNewsAutoScanService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "ReviewArticleDelay.queue"),
            exchange = @Exchange(name = "ReviewArticleDelay.direct",delayed = "true"),
            key = {"ReviewArticleDelay"}
    ))
    public void listenReviewArticleDelay(Integer id){
        try {
            wmNewsAutoScanService.autoScanWmNews(id);
        } catch (Exception e) {
            log.error("审核文章的消息发送失败，文章id：{}",id, e);
        }
    }

}
